package com.javakc.cms.book.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

/**
 * @ClassName Book
 * @Description 书籍信息管理 - 实体类
 * @Author xujie
 * @Date 2021/11/3
 * @Version 1.0.0
 **/
@Data
@Entity
@Table(name = "cms_book")
@EntityListeners(AuditingEntityListener.class)
public class Book {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    @ApiModelProperty(value = "书籍主键，采用数据库自增的方式")
    private Integer id ;

    @Column(name = "name")
    @ApiModelProperty(value = "书名")
    private String name ;

    @Column(name = "author")
    @ApiModelProperty(value = "作者")
    private String author ;

    @Column(name = "introduction")
    @ApiModelProperty(value = "简介")
    private String introduction ;

    @Column(name = "serial")
    @ApiModelProperty(value = "是否连载 1是 0否")
    private Integer serial ;

    @Column(name = "first")
    @ApiModelProperty(value = "一级分类")
    private Integer firstSort ;

    @Column(name = "second")
    @ApiModelProperty(value = "二级分类")
    private Integer secondSort ;

    @Column(name = "charge")
    @ApiModelProperty(value = "是否收费 1收费 0收费")
    private Integer charge ;

    @Column(name = "start_time")
    @ApiModelProperty(value = "授权开始时间")
    private Date startTime ;

    @Column(name = "end_time")
    @ApiModelProperty(value = "授权结束时间")
    private Date endTime ;

    @Column(name = "original")
    @ApiModelProperty(value = "是否原创 1是 0否")
    private Integer original ;

    @Column(name = "list_id")
    @ApiModelProperty(value = "书单外键")
    private Double listId ;

    @Column(name = "img_url")
    @ApiModelProperty(value = "书封")
    private String imgUrl ;

    @Column(name = "online")
    @ApiModelProperty(value = "上线状态 1上线 0未上线")
    private Integer online ;

    @Column(name = "bms_create",updatable = false)
    @ApiModelProperty(value = "创建时间", example = "2020-12-12 9:00:00")
    @CreatedDate
    @JsonFormat(pattern = "yyyy-MM-dd HH-mm-ss", timezone = "GMT+8")
    private Date bmsCreate ;

    @Column(name = "bms_modified",insertable = false)
    @ApiModelProperty(value = "更新时间", example = "2020-12-12 9:00:00")
    @LastModifiedDate
    @JsonFormat(pattern = "yyyy-MM-dd HH-mm-ss", timezone = "GMT+8")
    private Date bmsModified ;
}
